import { render } from 'vue';
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '开始时间',
    align: 'center',
    dataIndex: 'starttime',
  },
  {
    title: '结束时间',
    align: 'center',
    dataIndex: 'endtime',
  },
  {
    title: '学习状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  {
    title: '课程名称',
    align: 'center',
    dataIndex: 'muCourseName',
  },
  {
    title: '教师姓名',
    align: 'center',
    dataIndex: 'teacherName',
  },
  {
    title: '学生姓名',
    align: 'center',
    dataIndex: 'createBy',
  },
  {
    title: '是否签到',
    align: 'center',
    dataIndex: 'isSignString',
    customRender: ({ text }) => {
      return text == 'Y' ? '已签到' : '未签到';
    },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '学生姓名',
    field: 'createBy',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '课程名称',
    field: 'muCourseName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '教师姓名',
    field: 'teacherName',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '开始时间',
    field: 'starttime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入开始时间!' }];
    },
  },
  {
    label: '结束时间',
    field: 'endtime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入结束时间!' }];
    },
  },
  {
    label: '学习状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'study_status',
    },
  },
  {
    label: '课程名称',
    field: 'muCourseName',
    component: 'Input',
  },
  {
    label: '教师姓名',
    field: 'teacherName',
    component: 'Input',
  },
  {
    label: '是否签到',
    field: 'isSignString',
    component: 'JSwitch',
    componentProps: {},
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入是否签到!' }];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
